package simulator.ui;

import java.awt.Dimension;

import simulator.SchedulingScenario;

import simulator.software.Process;

/**
 * Swing component for rendering the state of a <code>SchedulingScenario</code>.
 * 
 * @author Kyle Loomis
 * 
 */
public class SchedulingScenarioRenderer extends ScenarioRenderer
{
   private static final long serialVersionUID = 1L;

   private SchedulingScenario scenario = null;

   /**
    * Default constructor.
    * 
    * @param scenario
    *           the scenario to render
    */
   public SchedulingScenarioRenderer(SchedulingScenario scenario)
   {
      this.scenario = scenario;

      createKernelComponent();
      createProcessComponents();
      createUtilizationChart();
      createProcessWaitChart();
   }

   private void createKernelComponent()
   {
      add(new KernelRenderer(scenario, scenario.getComputer().getKernel()));
   }

   private void createProcessComponents()
   {
      for (Process p : scenario.getComputer().getKernel().getProcesses())
      {
         add(new ProcessRenderer(scenario, p));
      }
   }

   private void createUtilizationChart()
   {
      UtilizationChart utilChart = new UtilizationChart(scenario);
      utilChart.setPreferredSize(new Dimension(360, 200));

      add(utilChart);
   }

   private void createProcessWaitChart()
   {
      ProcessWaitChart waitChart = new ProcessWaitChart(scenario);
      waitChart.setPreferredSize(new Dimension(500, 200));

      add(waitChart);
   }
}
